<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../lib/bootstrap-3.3.5-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/index.css">
    <link rel="stylesheet" href="../css/order.css">
    <link rel="stylesheet" href="../css/zx.css">
    <link rel="stylesheet" href="../font/iconfont.css">
    <script src="../lib/bootstrap-3.3.5-dist/js/jquery-1.11.3.js"></script>
    <script src="../lib/bootstrap-3.3.5-dist/js/bootstrap.min.js"></script>

</head>

<body>
    <div class="container-fluid " id="orderpage">
        <div class="kk"></div>
        <div id="cateHead">
            <p></p>
            <p>订单管理</p>
            <div class="litlehead">
                <span>全部</span>
            </div>
        </div>
    </div>
    <div id="catemain" class="container-fluid">
        <div class="catequery">
            <p class="tiaojianp">查询条件</p>
            <div class="row">
                <div class="col-md-3">
                    <label>订单编号:
                        <input type="text" class=" grayborder" id="orderid">
                    </label>
                </div>
                <div class="col-md-2 ">
                    <label>用户账户:
                        <input type="text" class="txtwidsaml  grayborder" id="ordername">
                    </label>
                </div>

                <div class="col-md-2">
                    <label>订单状态:
                        <select name="" id="orders" class="seclewidsaml grayborder">
                            <option value="全部">全部</option>
                            <option value="待付款">待付款</option>
                            <option value="待发货">待发货</option>
                            <option value="已发货">已发货</option>
                            <option value="已完成">已完成</option>
                            <option value="已取消">已取消</option>
                        </select>
                    </label>
                </div>
                <div class="col-md-3 mybutn">
                    <button class="myczbutn">重置</button>
                    <button class="myqurbutn">查询</button>
                    <button class="myxjbutn" id="gaoji">高级筛选</button>
                </div>
            </div>
        </div>
        <div id="tdheight">
            <div class="catetablehead mybutn threecolor">
                <p class="tiaojianp">商品列表</p>
                <button class=""> 合并订单</button>
                <button class="">打印快递单</button>
                <button class="">导出订单</button>
            </div>
            <table class="table">
                <thead>
                    <tr>
                        <th> <input type="checkbox" name="" id=""></th>
                        <th>订单编号</th>
                        <th>订单商品</th>
                        <th>订单金额</th>
                        <th>下单时间</th>
                        <th>用户账户</th>
                        <th>订单来源</th>
                        <th>支付方式</th>
                        <th>订单状态</th>
                        <th>操作</th>

                    </tr>
                </thead>
                <tbody id="mytbody">
                </tbody>
            </table>
            <div id="pagebut">

            </div>
        </div>

        <div id="motaikuang"></div>
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="myModalLabel">
                            高级筛选
                        </h4>
                    </div>
                    <div class="modal-body">
                        <table>
                            <tr>
                                <td>订单编号</td>
                                <td>用户账号</td>
                            </tr>
                            <tr>
                                <td><input type="text" id="gid"></td>
                                <td><input type="text" id="gname"></td>
                            </tr>
                            <tr>
                                <td>订单状态</td>
                                <td>订单来源</td>
                            </tr>
                            <tr>
                                <td>
                                    <select name="" id="orders2" class="seclewidsaml grayborder">
                                        <option value="全部">全部</option>
                                        <option value="待付款">待付款</option>
                                        <option value="待发货">待发货</option>
                                        <option value="已发货">已发货</option>
                                        <option value="已完成">已完成</option>
                                        <option value="已取消">已取消</option>
                                    </select>
                                </td>
                                <td>
                                    <select name="" id="orderl" class="seclewidsaml grayborder">
                                        <option value="全部">全部</option>
                                        <option value="App订单">App订单</option>
                                        <option value="PC订单">PC订单</option>
                                        <option value="小程序订单">小程序订单</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">下单日期</td>
                            </tr>
                            <tr>
                                <td colspan="2"><input type="date" id="gtime1">至<input type="date" id="gtime2"></td>
                            </tr>
                        </table>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal" id="chongzhi">重置</button>
                        <button type="button" class="btn btn-primary " data-dismiss="modal" id="gaojichaxun">查询</button>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-md-10 col-md-offset-2">
            <span class="foot1">大健康综合管理后台</span>
            <span class="foot2">版权所有:@大健康综合(集团)有限公司Meinian Onehealth Healthcare (Group)Co.</span>
            <span class="foot2">沪ICP备09017846号-3沪公网安备31010602006448号</span>
        </div>
        <script src="../JavaScript/data.js"></script>
        <!-- <script src="../JavaScript/mall.js"></script> -->
        <script src="../JavaScript/utils.js"></script>
        <script src="../JavaScript/index.js"></script>
        <script>
            var myorderData = getmyData("orderData")
            if (myorderData == null) {
                setmyData("orderData", orderData)
                myorderData = getmyData("orderData")
            }
            console.log(myorderData)
            showTable(8, myorderData)
            // console.log($('td:nth-of-type(3)'));
            function mysepcil() {
                let sepc1 = document.querySelectorAll('#mytbody td:nth-of-type(1)')
                let sepc2 = document.querySelectorAll('#mytbody td:last-of-type')
                $(sepc1).before(`<td><input type="checkbox" name="" id=""></td>`)

                for (let o = 0; o < sepc2.length; o++) {
                    $(sepc2[o]).after(`<td><button class='myclose'>关闭订单</button><span href="" class='chaxun'>查看订单</span></td>`)
                }
                $(`td>button`).css({
                    margin: '0 10px',
                    backgroundColor: '#fff',
                    color: 'rgba(24, 144, 255, 1)'
                })
                $('.myclose').click(function () {
                    console.log(123)
                    let x = $(this).parent().parent().children().eq(1).html()
                    $.each(myorderData, function (index, item) {
                        if (item.orderCode == x) {
                            item.orderStatus = '已关闭'
                        }
                    })
                    // $(this).remove()
                    showTable(8, myorderData)
                    setmyData('orderData', myorderData)
                })
            }
            let txarry = []
            $('.myqurbutn').click(function () {
                console.log(123)
                for (let i = 0; i < myorderData.length; i++) {
                    if (myorderData[i].orderCode == $('#orderid').val() && (myorderData[i].goodsName == $('#ordername').val())) {
                        txarry.push(myorderData[i])
                    }
                    if (myorderData[i].orderCode == $('#orderid').val()) {
                        txarry.push(myorderData[i])
                    }
                    if (myorderData[i].goodsName == $('#ordername').val()) {
                        txarry.push(myorderData[i])
                    }
                    if (myorderData[i].orderStatus == $('#orders').val() && $('#orderid').val() == '' && $('#ordername').val() == '') {
                        txarry.push(myorderData[i])
                    }
                }
                console.log(txarry);
                showTable(8, txarry)
                txarry = []
            })
            $("#gaoji").click(function () {
                $('#gaoji').attr('data-toggle', 'modal')
                $('#gaoji').attr('data-target', '#myModal')
            })

            $('#gaojichaxun').click(function () {
                let mydata1 = []
                for (let i = 0; i < myorderData.length; i++) {
                    if (myorderData[i].orderCode == $('#gid').val() && (myorderData[i].goodsName == $('#gname').val())) {
                        txarry.push(myorderData[i])
                    }
                    if (myorderData[i].orderCode == $('#gid').val()) {
                        txarry.push(myorderData[i])
                    }
                    if (myorderData[i].goodsName == $('#gname').val()) {
                        txarry.push(myorderData[i])
                    }
                    // if (myorderData[i].orderStatus == $('#orders2').val()&&$('#gid').val()==''&&$('#gname').val()=='') {
                    //     txarry.push(myorderData[i])
                    //     console.log(4)
                    // }
                    if (new Date(myorderData[i].orderTime) > new Date($('#gtime1').val()) && new Date(myorderData[i].orderTime) < new Date($('#gtime2').val()) && (myorderData[i].orderSource == $('#orderl').val()) && (myorderData[i].orderStatus == $('#orders2').val())) {
                        txarry.push(myorderData[i])
                        console.log('my1')
                    }
                    else if (new Date(myorderData[i].orderTime) > new Date($('#gtime1').val()) && new Date(myorderData[i].orderTime) < new Date($('#gtime2').val()) && (myorderData[i].orderSource == $('#orderl').val()) && $('#orders2').val() == '全部') {
                        txarry.push(myorderData[i])
                        console.log('my2')
                    }
                    else if (new Date(myorderData[i].orderTime) > new Date($('#gtime1').val()) && new Date(myorderData[i].orderTime) < new Date($('#gtime2').val()) && (myorderData[i].orderStatus == $('#orders2').val()) && $('#orderl').val() == '全部') {
                        txarry.push(myorderData[i])
                        console.log('my3')
                    }
                    else if ((myorderData[i].orderSource == $('#orderl').val()) && (myorderData[i].orderStatus == $('#orders2').val()) && $('#gtime1').val() == '' && $('#gtime2').val() == '') {
                        txarry.push(myorderData[i])
                        console.log('my4')
                    }
                    else if (new Date(myorderData[i].orderTime) > new Date($('#gtime1').val()) && new Date(myorderData[i].orderTime) < new Date($('#gtime2').val()) && (myorderData[i].orderSource == '全部') && ($('#orders2').val() == '全部')) {
                        txarry.push(myorderData[i])
                        console.log('my5')
                    }
                    else if ((myorderData[i].orderSource == $('#orderl').val()) && ($('#orders2').val() == '全部')) {
                        txarry.push(myorderData[i])
                        console.log('my6')
                    }
                    else if (($('#orderl').val() == '全部') && (myorderData[i].orderStatus == $('#orders2').val())) {
                        txarry.push(myorderData[i])
                        console.log('my7')
                    }
                }
                console.log(txarry)
                showTable(8, txarry)
                txarry = []
            })
            $("#chongzhi").click(function () {
                showTable(8, myorderData)
                $('#gtime1').val() = 'yyyy/mm/日'
                $('#gtime2').val() = 'yyyy/mm/日'
                $('#orderl').val() = '全部'
                $('#orders2').val() = '全部'
            })
            $(".chaxun").click(function () {
                location.href = './order_1.html'
                // console.log(123)
                setmyData('order_next', $(this).parent().parent().children().eq(1).text())
            })
        </script>

</body>

</html>